package com.lookoutthebush.companyindex.dao;

import com.lookoutthebush.companyindex.domain.NewsTypesDO;
import com.lookoutthebush.companyindex.util.MyJdbcDAO;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

@Repository
public class NewsTypesDAO {
    @Resource
    private MyJdbcDAO jdbcDAO;

    public Long insert(NewsTypesDO newsTypesDO){
        jdbcDAO.create(newsTypesDO);
        return newsTypesDO.getId();
    }

    public NewsTypesDO queryById(Long id){
        return jdbcDAO.queryById(id, NewsTypesDO.class);
    }

    public boolean update(NewsTypesDO newsTypesDO){
        jdbcDAO.update(newsTypesDO);
        return true;
    }

    public List<NewsTypesDO> queryAllValidTypes(){
        String sql = "select * from newstypes where delete = 0";
        return jdbcDAO.queryList(sql, Collections.emptyMap(), NewsTypesDO.class);
    }
}
